package com.xuexiang.xuidemo.slice.status;

import com.xuexiang.xui_lib.component.status.StatusLoader;
import com.xuexiang.xuidemo.ResourceTable;
import com.xuexiang.xuidemo.slice.BaseAbilitySlice;
import com.xuexiang.xuidemo.slice.status.adapter.SingleViewAdapter;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;

public class StatusLoaderSingleSlice extends BaseStatusLoaderSlice {

    private ComponentContainer llContent;

    @Override
    protected int getTitleBarId() {
        return ResourceTable.Id_title_bar;
    }

    @Override
    protected int getUIContentLayoutId() {
        return ResourceTable.Layout_status_loader_layout;
    }

    @Override
    protected void initComponents() {
        super.initComponents();
        mTitleBar.setTitle("StatusLoader组件复用");
        llContent = (ComponentContainer) findComponentById(ResourceTable.Id_ll_content);
        showLoading();
    }

    @Override
    protected Component getWrapView() {
        return llContent;
    }

    @Override
    protected StatusLoader.Adapter getStatusLoaderAdapter() {
        return new SingleViewAdapter();
    }

    @Override
    public void onClickMenu(Component component) {
        super.onClickMenu(component);
        switch (component.getId()) {
            case ResourceTable.Id_fb_loading:
                showLoading();
                break;
            case ResourceTable.Id_fb_empty:
                showEmpty();
                break;
            case ResourceTable.Id_fb_error:
                showError();
                break;
            case ResourceTable.Id_fb_net_work_error:
                showCustom();
                break;
            case ResourceTable.Id_fb_comment:
                showContent();
                break;
        }
    }
}
